<article class="module width_full">
<header>
    <h3 class="tabs_involved">Permissions Admin Advance</h3>
    <a href='/admin/permissions' >Basic</a>
</header>
    
<?php
echo $this->partial('partials/permissionText.phtml',array(
            'add' => $this->add,
            'delete' => $this->delete
));
?>
    
<div class="tab_container">
    <div id="tab1" class="tab_content">
        <table class="tablesorter" cellspacing="0"> 
        <thead>
            <tr>
                <th class="nobg">Controlador</th>
                <th>Accion</th>
                <?php foreach ($this->roles as $role) { ?>
                    <th><?php echo $role['role']; ?></th>
                <?php } ?>
            </tr>
        </thead>
        <?php
        $type = "";
        $i=0;
        foreach ($this->controllerAction as $ConAct):
            if ($i%2==0){
                $classth = 'class="spec"';
                $classtd = '';
            }else{
                $classth = 'class="specalt"';
                $classtd = 'class="alt"';
            }
            $i++;
            if ($type != $ConAct['module']): ?>
                <tr>
                    <td class="none" colspan="<?php echo count($this->roles) + 2; ?>" >
                        <?php echo $ConAct['module'] ?>
                    </td>
                </tr>
                <?php
                $type = $ConAct['module'];
            endif; ?>
            <tr>
                <td <?php echo ($controllerNow == $ConAct['controller']) ? 'class="nobgmiddle"' : $classth; ?> ><?php echo ($controllerNow == $ConAct['controller'] ) ? '' : $ConAct['controller']; ?></td>
                <td <?php echo $classtd;?> ><?php echo $ConAct['action']; ?></td>
                <?php
                foreach ($this->roles as $role):
                    $select = "";
                    foreach ($this->ACL as $ACL):
                        if (($ACL['id_action'] == $ConAct['id'] ) && ( $ACL['id_role'] == $role['id']) && ($ACL['access'] == 1)):
                            $select = "checked";
                        endif;
                    endforeach; ?>
                    <td <?php echo $classtd;?> ><input <?php echo $select; ?> onchange='guardarPermiso("<?php echo $ConAct['controller'] . "-" . $ConAct['action'] . "-" . $role['id']; ?>","")' type="checkbox" id="<?php echo $ConAct['controller'] . "-" . $ConAct['action'] . "-" . $role['id']; ?>" name="<?php echo $ConAct['controller'] . "-" . $ConAct['action'] . "-" . $role['id']; ?>" value="" /></td>
                <?php endforeach; ?>
            </tr>
            <?php
            $controllerNow = $ConAct['controller'];
        endforeach; ?>
    </table>
</div>
    
</article>